package com.promote.algorithm;

/**
 * @ClassName ReverseString
 * Description 反转字符串
 * @Author LiZiHao
 * Date 2022/3/10 15:34
 * @Version 1.0
 **/
public class ReverseString {

    public void reverseString(char[] s) {
        int length = s.length;

        int left = 0;
        int right = length - 1;

        while (left < right) {
            swap(s,left++,right--);
        }

    }
    public void swap(char[] s,int left,int right) {
        char temp = s[left];
        s[left] = s[right];
        s[right] = temp;
    }
}
